<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/DatePicker.js"></script>
	<script type="application/javascript" src="../layui/layui.js"></script>
	<script type="application/javascript" src="../js/vue.min.js"></script>
<title>车辆添加页面</title>
</head>
<body>
	<div class="row" style="margin-left: 20px;">
		<form method="post" enctype="multipart/form-data">
			<div>
				<h3>新增车辆</h3>
			</div>
			<hr />
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-inline">
						<label>车辆名称:</label>
						<input type="text" name="name" class="form-control" />
					</div>
					
					<div class="form-group form-inline">
						<label>汽车类型:</label>
						<select name="type" class="form-control">
							<option value="自排">自排</option>
							<option value="手排">手排</option>
							<option value="手自一体">手自一体</option>
						</select>
					</div>

					<div class="form-group form-inline">
						<label>库存:</label>
						<input type="text" name="number" class="form-control" />
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-inline">
						<label>价格:</label>
						<input type="text" name="price" class="form-control" />
					</div>
					<div class="form-group form-inline">
						<label>座位数:</label>
						<input type="text" name="sitnum" class="form-control" />
					</div>

				</div>
			</div>
			<div class="row">
				<div class="col-sm-10">

					<div class="form-group form-inline">
						<input type="submit" value="添加" class="btn btn-primary" lay-submit="" lay-filter="demo1" />
						<input type="reset" value="重置" class="btn btn-default" />
					</div>
				</div>
			</div>
		</form>
	</div>
	<script>
		layui.use(['form'], function(){
			var form = layui.form;


			//监听提交
			form.on('submit(demo1)', function(data){
				$.ajax({
					url:"addCar",
					type:"post",
					data:$("form").serialize(),
					dataType:'json',
					success:function(res) {
						if(res.statusCode == 200) {
							alert(res.msg);

						} else {
							layer.alert("添加失败");
						}
					},
					error: function() {
						alert("ajax错误");
					}
				});
				return false;

			});
		});
	</script>


</body>
</html>